A Layer 2 Virtual Private Network (L2VPN) can enable multiple local area networks (LAN), distributed in geographical positions, to perform Layer 2 communication by using a public network. The public network may be, but not limited to, a public Multi-Protocol Label Switching (MPLS) network, or may be another network that can run a label protocol. For example, in FIG. 1, local area network N1 and local area network N2 belong to L2VPN A, and L2VPN A includes local area network N1, local area network N2, and a public MPLS network connected between N1 and N2. For example, N1 may be a local area network of corporation A in Beijing, N2 may be another local area network of corporation A in Shanghai, N1 and N2 may perform communication by using a public MPLS network, and N3 and N4 belong to another L2VPN B, and also perform communication by using the public MPLS network. When Layer 2 communication is performed between any two local area networks of an L2VPN, a packet transmitted between the two local area networks is encapsulated in a tunnel when passing through a public MPLS network, where the tunnel is a unidirectional link formed by routers in the public MPLS network. When the packet is transmitted in the public MPLS network, two layers of labels, namely, a tunnel label and a network label, are encapsulated. The tunnel label is used to identify a tunnel in which the packet is located when the packet is forwarded, and the network label is used to identify each local area network of the L2VPN, that is, a destination local area network to which the packet is transmitted. When being forwarded, the packet is no longer forwarded according to header information of an original packet, but is forwarded according to the label. Referring to FIG. 1, before a packet is transmitted between any two local area networks of an L2VPN, the Label Distribution Protocol (LDP) is run between all adjacent routers in a public MPLS network (for example, between PE1 and P2, and between P2 and PE2 in FIG. 1) to establish a tunnel. Then, a router that the tunnel passes by views a label resource table of the router, selects a label, not occupied by the router, as a tunnel label of the packet for future packet forwarding processing, and indicates tunnel label processing information of the router. Subsequently, the Label Distribution Protocol or the Multiprotocol Extensions for Border Gateway Protocol (MP-BGP) is run between router PE1 at a tunnel ingress and router PE2 at a tunnel egress, to determine, for PE1 and PE2, a network label of the packet for future forwarding processing, and indicate network label processing information. Each router that the tunnel passes by then accordingly generates routing control information of each router according to path information of the tunnel, a label corresponding to the router, and label processing information corresponding to the label, for each router to process and forward the packet.
In a research process of the application, the inventor finds that the prior art at least has the following defects:
A label-related protocol needs to be run between routers in a public network to determine a tunnel in which a packet is transmitted between any two local area networks of an L2VPN, and a router needs to allocate a label to the router itself, indicate label processing information, and generate routing control information of the router. As a result, a calculation overhead of the router in the public network is large.